package com.ruoyi.fs.service.impl;

import java.util.List;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.fs.mapper.FsBillMapper;
import com.ruoyi.fs.domain.FsBill;
import com.ruoyi.fs.service.IFsBillService;

/**
 * 还款账单Service业务层处理
 *
 * @author hero
 * @date 2024-09-09
 */
@Service
public class FsBillServiceImpl implements IFsBillService {
    @Autowired
    private FsBillMapper fsBillMapper;

    /**
     * 查询还款账单
     *
     * @param id 还款账单主键
     * @return 还款账单
     */
    @Override
    public FsBill selectFsBillById(Long id) {
        return fsBillMapper.selectFsBillById(id);
    }

    /**
     * 查询还款账单
     *
     * @param caseId 还款账单主键
     * @return 还款账单
     */
    @Override
    public FsBill selectFsBillByCaseId(Long caseId) {
        FsBill query = new FsBill();
        query.setCaseId(caseId);
        List<FsBill> list = fsBillMapper.selectFsBillList(query);
        if (list.isEmpty()) {
            return null;
        } else {
            return list.get(0);
        }
    }

    /**
     * 查询还款账单列表
     *
     * @param fsBill 还款账单
     * @return 还款账单
     */
    @Override
    public List<FsBill> selectFsBillList(FsBill fsBill) {
        return fsBillMapper.selectFsBillList(fsBill);
    }

    /**
     * 新增还款账单
     *
     * @param fsBill 还款账单
     * @return 结果
     */
    @Override
    public int insertFsBill(FsBill fsBill) {
        fsBill.setCreateTime(DateUtils.getNowDate());
        return fsBillMapper.insertFsBill(fsBill);
    }

    /**
     * 修改还款账单
     *
     * @param fsBill 还款账单
     * @return 结果
     */
    @Override
    public int updateFsBill(FsBill fsBill) {
        fsBill.setUpdateTime(DateUtils.getNowDate());
        return fsBillMapper.updateFsBill(fsBill);
    }

    /**
     * 批量删除还款账单
     *
     * @param ids 需要删除的还款账单主键
     * @return 结果
     */
    @Override
    public int deleteFsBillByIds(Long[] ids) {
        return fsBillMapper.deleteFsBillByIds(ids);
    }

    /**
     * 删除还款账单信息
     *
     * @param id 还款账单主键
     * @return 结果
     */
    @Override
    public int deleteFsBillById(Long id) {
        return fsBillMapper.deleteFsBillById(id);
    }
}
